// PART 3 PRODUCES RESULTS FOR TABLES 8 AND 9

clear
cd "\\file\UsersW$\wrr15\Home\My Documents\My Files\XINDONG XUE\META-ANALYSIS\REVISION FOR JHE\DATA AND CODE"
set more off
set type double
graph drop _all
program drop _all
set scheme s2mono
log using "Part3 Results(20191130).smcl", replace
use "sc_data(20191130).dta"

******************************************************************************
*DEFINITION OF BASIC VARIABLES
******************************************************************************
gen tstat = real(tstatistics)
gen negative = 1
replace negative = -1 if ((badhealth == 1 & badsc == 0) | (badhealth == 0 & badsc == 1))
replace tstat = tstat*negative
gen df = nobs
gen obsno = _n
replace df = . if tstat == .
gen r = tstat/sqrt(tstat^2+df)
gen varR = (1-r^2)/df
gen seR = sqrt(varR)
gen pcc = r

quietly summ pcc, detail
keep if pcc > r(p1) & pcc < r(p99) 

// Calculating study weights
bysort id: egen numberests = count(id)
tabulate numberests 
gen weight = 1/numberests

// Study Type
describe journal
gen journal2 = journal
encode journal, gen(njournal)
drop journal
gen journal=(njournal != .)

// Countries
gen eastasia=(country_region=="East_Asia")
gen usa=(country_region=="USA")
gen westnortheurope=(country_region=="West_North_Europe")
gen highincome=(country_region=="High-income countries")
gen othercountry = 1 - eastasia - usa - westnortheurope - highincome

// Social Capital Measures
gen cognitive = (cognitivestructual == 0)
replace cognitive = . if cognitivestructual == .
gen structural = (cognitivestructual == 1)
replace structural = . if cognitivestructual == .
gen bonding = (bondingbridginglinking == 0)
replace bonding = . if bondingbridginglinking == .
gen bridging = (bondingbridginglinking == 1)
replace bridging = . if bondingbridginglinking == .
gen linking = (bondingbridginglinking == 2)
replace linking = . if bondingbridginglinking == .
sum bondingbridginglinking bonding bridging linking

quietly summ numberofscvariables
// We replace numberofscvariables with deviation from mean
replace numberofscvariables = numberofscvariables - r(mean)

// Estimation Method
gen otherestimation = 1 - ols - fgls - probitlogit - orderedprobitlogit - orhr - hlm - iv 
quietly summ numberofscvariables
// We replace numberofscvariables with deviation from mean
replace numberofscvariables = numberofscvariables - r(mean)

// Calculation of t-statistic
gen tcalculatedbyci=(tcalculatedbycise==1 & cilowerbound != .)
gen tcalculatedbypvalue2 = tcalculatedbypvalue
replace tcalculatedbypvalue = (tcalculatedbypvalue2 == 1)
gen tnormal = 1 - tcalculatedbyci - tcalculatedbypvalue

// Generating transformed variables for FE and RE
gen fetstatR = r/seR
metareg r seR pubyear panel iv eastasia westnortheurope highincome othercountry ///
physicalhealth mentalhealth selfreported cognitivestructual bondingbridginglinking ///
numberofscvariables age gender education maritalstatus income ols orhr hlm ///
seother tnormal tcalculatedbypvalue, wsse(seR)
scalar tau2 =  e(tau2)
gen revarR = varR + tau2
gen reseR = sqrt(revarR)
gen retstatR = r/reseR
gen repubbiasR = seR/reseR

************************************
************************************
************************************
************ TABLE 8 ***************
************************************
************************************
************************************

*------------*
*   Panel A  *
*------------*
summ cognitive structural bonding bridging linking
*------------*
*   Panel B  *
*------------*
summ pcc if cognitive == 1
summ pcc if structural == 1
summ pcc if bonding == 1
summ pcc if bridging == 1
summ pcc if linking == 1


************************************
************************************
************************************
************ TABLE 9 ***************
************************************
************************************
************************************

**********************************************
************ FIXED EFFECTS *******************
**********************************************
gen conss = 1/seR
gen cognitivee = cognitive/seR
gen bondingg= bonding/seR
gen bridgingg = bridging/seR
gen pubyearr = pubyear/seR
gen individualscc = individualsc/seR
gen panell = panel/seR
gen ivv = iv/seR
gen eastasiaa = eastasia/seR
gen westnortheuropee = westnortheurope/seR
gen highincomee = highincome/seR
gen othercountryy = othercountry/seR
gen physicalhealthh = physicalhealth/seR
gen mentalhealthh = mentalhealth/seR
gen selfreportedd = selfreported/seR
gen numberofscvariabless = numberofscvariables/seR
gen agee = age/seR
gen genderr = gender/seR
gen educationn = education/seR
gen maritalstatuss = maritalstatus/seR
gen incomee = income/seR
gen olss = ols/seR
gen orhrr = orhr/seR
gen hlmm = hlm/seR
gen seotherr = seother/seR
gen tnormall = tnormal/seR
gen tcalculatedbypvaluee = tcalculatedbypvalue/seR
gen cogphysicall = cognitive*physicalhealth/seR
gen cogmentall = cognitive*mentalhealth/seR
gen bondphysicall = bonding*physicalhealth/seR
gen bondmentall = bonding*mentalhealth/seR

// NOTE: The constant term is the SER term

*--------------------------------------------------------*
*   TABLE: FixedEffects(Weight1) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss cognitivee pubyearr individualscc panell eastasiaa westnortheuropee physicalhealthh mentalhealthh selfreportedd numberofscvariabless ///
agee educationn incomee olss hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, vce(cluster id)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if physicalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss cognitivee pubyearr panell ivv westnortheuropee ///
selfreportedd agee genderr educationn maritalstatuss incomee olss seotherr ///
tcalculatedbypvaluee if esample == 1, vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if mentalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss cognitivee panell eastasiaa westnortheuropee ///
highincomee selfreportedd numberofscvariabless educationn olss orhrr seotherr ///
tnormall tcalculatedbypvaluee if esample == 1, vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if generalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss cognitivee individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd numberofscvariabless educationn  maritalstatuss ///
olss hlmm seotherr tcalculatedbypvaluee if esample == 1, vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee cogphysicall cogmentall pubyearr ///
individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss cognitivee cogphysicall cogmentall)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss cognitivee cogphysicall cogmentall pubyearr individualscc panell eastasiaa ///
westnortheuropee othercountryy physicalhealthh mentalhealthh ///
selfreportedd numberofscvariabless agee educationn incomee olss hlmm  seotherr tnormall ///
tcalculatedbypvaluee if esample == 1, vce(cluster id)

*--------------------------------------------------------*
*   TABLE: FixedEffects(Weight2) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
selfreportedd numberofscvariabless genderr educationn maritalstatuss ///
olss hlmm tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, vce(cluster id) 

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if physicalhealth == 1 
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss cognitivee pubyearr panell ivv westnortheuropee ///
selfreportedd numberofscvariabless educationn incomee olss orhrr ///
seotherr tcalculatedbypvaluee [pweight = weight] if esample == 1, vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if mentalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss cognitivee pubyearr individualscc panell eastasiaa westnortheuropee ///
highincomee numberofscvariabless agee educationn maritalstatuss incomee olss orhrr ///
hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight]  if esample == 1, vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if generalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1 , ///
backward bic fix(conss cognitivee)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss cognitivee individualscc panell eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss cognitivee pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] 
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1 , backward bic fix(conss cognitivee ///
cogphysicall cogmentall)

regress fetstatR conss cognitivee cogphysicall cogmentall pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
mentalhealthh selfreportedd numberofscvariabless ///
educationn maritalstatuss olss hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, vce(cluster id)


***********************************************
************ RANDOM EFFECTS *******************
***********************************************
replace conss = 1/reseR
replace cognitivee = cognitive/reseR
replace bondingg= bonding/reseR
replace bridgingg = bridging/reseR
replace pubyearr = pubyear/reseR
replace individualscc = individualsc/reseR
replace panell = panel/reseR
replace ivv = iv/reseR
replace eastasiaa = eastasia/reseR
replace westnortheuropee = westnortheurope/reseR
replace highincomee = highincome/reseR
replace othercountryy = othercountry/reseR
replace physicalhealthh = physicalhealth/reseR
replace mentalhealthh = mentalhealth/reseR
replace selfreportedd = selfreported/reseR
replace numberofscvariabless = numberofscvariables/reseR
replace agee = age/reseR
replace genderr = gender/reseR
replace educationn = education/reseR
replace maritalstatuss = maritalstatus/reseR
replace incomee = income/reseR
replace olss = ols/reseR
replace orhrr = orhr/reseR
replace hlmm = hlm/reseR
replace seotherr = seother/reseR
replace tnormall = tnormal/reseR
replace tcalculatedbypvaluee = tcalculatedbypvalue/reseR
replace cogphysicall = cognitive*physicalhealth/reseR
replace cogmentall = cognitive*mentalhealth/reseR
replace bondphysicall = bonding*physicalhealth/reseR
replace bondmentall = bonding*mentalhealth/reseR

*---------------------------------------------------------*
*   TABLE: RandomEffects(Weight1) // Stepwise Regression  *
*---------------------------------------------------------*

// NOTE: For Random Effects models, SE/reseR is not equal to 1. This causes a problem because the
// stepwise regression command does not have a "noconstant" option. Our solution is to run the stepwise
// regression with the constant term, then drop it in the final equation.	   
		  
////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy physicalhealthh ///
mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy physicalhealthh mentalhealthh selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss cognitivee individualscc panell westnortheuropee othercountryy ///
physicalhealthh mentalhealthh numberofscvariabless genderr educationn seotherr  ///
tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if physicalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss cognitivee panell westnortheuropee  ///
highincomee genderr educationn olss seotherr tnormall ///
tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if mentalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss cognitivee pubyearr individualscc panell westnortheuropee  ///
othercountryy numberofscvariabless educationn orhrr seotherr tnormall ///
tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if generalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss cognitivee individualscc panell highincomee  ///
othercountryy selfreportedd numberofscvariabless educationn orhrr  ///
tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy physicalhealthh ///
mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee , ///
backward bic fix(conss cognitivee cogphysicall cogmentall)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss cognitivee cogphysicall cogmentall individualscc panell ///
westnortheuropee othercountryy physicalhealthh mentalhealthh numberofscvariabless ///
genderr educationn olss seotherr tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

*--------------------------------------------------------*
*   TABLE: RandomEffects(Weight2) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy physicalhealthh ///
mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy physicalhealthh mentalhealthh selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss cognitivee repubbiasR  pubyearr individualscc panell eastasiaa ///
westnortheuropee selfreportedd numberofscvariabless educationn olss seotherr  ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if physicalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss cognitivee pubyearr individualscc panell westnortheuropee  ///
highincomee numberofscvariabless educationn olss hlmm tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if mentalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss cognitivee individualscc panell   ///
westnortheuropee numberofscvariabless agee educationn orhrr  ///
hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy  ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if generalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss cognitivee)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss cognitivee individualscc westnortheuropee  ///
othercountryy selfreportedd numberofscvariabless agee educationn incomee   ///
tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR cognitivee pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy physicalhealthh ///
mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy physicalhealthh mentalhealthh selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] ///
if esample == 1, backward bic fix(conss cognitivee cogphysicall cogmentall)

regress retstatR conss cognitivee cogphysicall cogmentall repubbiasR pubyearr individualscc panell ///
eastasiaa westnortheuropee physicalhealthh mentalhealthh selfreportedd numberofscvariabless ///
agee genderr educationn olss seotherr tcalculatedbypvaluee [pweight = weight] ///
if esample == 1, noc vce(cluster id)


log close

 